<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="zh-CN">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
 <script type='text/javascript' src='jsbn.js'></script>
 <script type='text/javascript' src='jsbn2.js'></script>
 <script type='text/javascript' src='rsa.js'></script>

<body>
<?php
include "BigInteger.php";
include "BigIntext.php";
include('rsa.class.php');

$RSA = new RSA();
$keys = $RSA->generate_keys ('62700433', '62702257', 1);
$message='
       <h2 class="pageTitle">.Net Framework 4.0: Introducing BigInteger</h2>

       <p>My previous posting was about <a href="http://weblogs.asp.net/gunnarpeipman/archive/2009/05/23/performance-of-fibonacci-numbers-algorithms.aspx" target="_blank">performance of Fibonacci numbers algorithms</a>. In this posting I will introduce you some problems related to limits of our usual integers and introduce you new feature in .Net Framework 4.0 – big integers. Big integers are useful when solving different mathematical problems. Also they are used in cryptography.</p>  <p>As a first thing let’s see the problem we may face when we use our usual integers. Let’s use faster implementation of Fibonacci numbers algorithm so we don’t have to wait a long time to get results we need.</p> <strong>C#</strong><span style="widows: 2; text-transform: none; text-indent: 0px; border-collapse: separate; font-family: tahoma; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px;" class="Apple-style-span">    <hr size="1">    <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">     <pre style="margin: 0px;"><span style="color: blue;">public</span> <span style="color: blue;">int</span> Fibonacci(<span style="color: blue;">int</span> x)</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">{</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">var</span> previousValue = -1;</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">var</span> currentResult = 1;</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">for</span> (<span style="color: blue;">var</span> i = 0; i &lt;= x; ++i)</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue;">var</span> sum = currentResult + previousValue;</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; previousValue = currentResult;</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currentResult = sum;</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> currentResult;</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <pre style="margin: 0px;">}</pre>
  </div>

  <div style="background-color: white; font-family: \'courier new\'; color: black; font-size: 10pt;">
    <hr size="1"></div>
</span>

<p><strong>VB.NET</strong><span style="widows: 2; text-transform: none; text-indent: 0px; border-collapse: separate; font-family: tahoma; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px;" class="Apple-style-span"> 
    <br class="Apple-interchange-newline"></span></p>

<hr size="1"><span style="widows: 2; text-transform: none; text-indent: 0px; border-collapse: separate; font-family: \'Courier New\'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; white-space: nowrap; orphans: 2; letter-spacing: normal; color: rgb(0, 0, 187); word-spacing: 0px;" class="Apple-style-span"><span style="color: rgb(255, 128, 0);" class="kw2">Public</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(6, 0, 255);" class="kw6">Function</span><span class="Apple-converted-space">&nbsp;</span>Fibonacci<span style="color: rgb(0, 0, 0);" class="br0">(</span><span style="color: rgb(255, 128, 0);" class="kw2">ByVal</span><span class="Apple-converted-space">&nbsp;</span>x<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">As</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 0, 0);" class="kw4">Integer</span><span style="color: rgb(0, 0, 0);" class="br0">)</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">As</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 0, 0);" class="kw4">Integer</span><span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp; <span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(6, 0, 255);" class="kw6">Dim</span><span class="Apple-converted-space">&nbsp;</span>previousValue<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">-</span>1<span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp; <span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(6, 0, 255);" class="kw6">Dim</span><span class="Apple-converted-space">&nbsp;</span>currentResult<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span>1<span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp; <span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp; <span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">For</span><span class="Apple-converted-space">&nbsp;</span>i<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span>0<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">To</span><span class="Apple-converted-space">&nbsp;</span>x<span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(6, 0, 255);" class="kw6">Dim</span><span class="Apple-converted-space">&nbsp;</span>sum<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span>currentResult<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">+</span><span class="Apple-converted-space">&nbsp;</span>previousValue<span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; previousValue<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span>currentResult<span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currentResult<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span>sum<span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp; <span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">Next</span><span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp; <span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp; <span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">Return</span><span class="Apple-converted-space">&nbsp;</span>currentResult<span class="Apple-converted-space">&nbsp;</span> 

  <br><span style="color: rgb(6, 0, 255);" class="kw6">End</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(6, 0, 255);" class="kw6">Function</span></span> 

<hr size="1">

<p></p>

<p></p>

<div style="float: right; margin-left: 10px;">
  <table border="1" cellpadding="2" cellspacing="0"><thead>
      <tr>
        <th>Input</th>

        <th>Actual</th>

        <th>Expected</th>
      </tr>
    </thead><tbody>
      <tr>
        <td>40</td>

        <td align="right">102334155</td>

        <td align="right">102334155</td>
      </tr>

      <tr>
        <td>41</td>

        <td align="right">165580141</td>

        <td align="right">165580141</td>
      </tr>

      <tr>
        <td>42</td>

        <td align="right">267914296</td>

        <td align="right">267914296</td>
      </tr>

      <tr>
        <td>43</td>

        <td align="right">433494437</td>

        <td align="right">433494437</td>
      </tr>

      <tr>
        <td>44</td>

        <td align="right">701408733</td>

        <td align="right">701408733</td>
      </tr>

      <tr>
        <td>45</td>

        <td align="right">1134903170</td>

        <td align="right">1134903170</td>
      </tr>

      <tr>
        <td>46</td>

        <td align="right">1836311903</td>

        <td align="right">1836311903</td>
      </tr>

      <tr>
        <td>47</td>

        <td align="right">-1323752223</td>

        <td align="right">2971215073</td>
      </tr>

      <tr>
        <td>48</td>

        <td align="right">512559680</td>

        <td align="right">4807526976</td>
      </tr>

      <tr>
        <td>49</td>

        <td align="right">-811192543</td>

        <td align="right">7778742049</td>
      </tr>

      <tr>
        <td>50</td>

        <td align="right">-298632863</td>

        <td align="right">12586269025</td>
      </tr>
    </tbody></table>
</div>

<p>Now let’s take some value range where we can expect big numbers as result. Let’s take range from 40 to 50 and compare the results of our algorithm with expected results.</p>

<p>We can see that starting from 47 our results are different. 47 is the point where we go over integer limits and then we go to “next round” in integer scope. Same thing happens also with unsigned integer, long and unsigned long.</p>

<p>If we take some bigger input for our algorithm then we will get even larger numbers. 47 is small number and I am sure that scientific calculations use usually bigger inputs too and breaking over the limits of used type is almost sure. </p>

<p>You may also consider some other algorith that produces faster growth of results. Perfect candidate for this is factorial algorithm. By example 40! = 815915283247897734345611269596115894272000000000.</p>

<h3>Introducing BigInteger class</h3>

<p>.Net Framework 4.0 solves our problem. New namespace <a href="http://msdn.microsoft.com/en-us/library/system.numerics%28VS.100%29.aspx" target="_blank">System.Numerics</a> contains class called <a href="http://msdn.microsoft.com/en-us/library/system.numerics.biginteger%28VS.100%29.aspx" target="_blank">BigInteger</a>. You can use objects based on this class as usual integers. This class also provides static methods for different mathematical operations on big integers. Let’s move now to BigInteger class with our Fibonacci numbers algorithm.</p>
<strong>C#</strong> 

<hr size="1">

<pre style="margin: 0px;"><span style="color: blue;">public</span> <span style="color: rgb(43, 145, 175);">BigInteger</span> Fibonacci(<span style="color: blue;">int</span> x)</pre>

<pre style="margin: 0px;">{</pre>

<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">var</span> previousValue = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">BigInteger</span>(-1);</pre>

<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">var</span> currentResult = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">BigInteger</span>(1);</pre>

<pre style="margin: 0px;">&nbsp;</pre>

<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">for</span> (<span style="color: blue;">var</span> i = 0; i &lt;= x; ++i)</pre>

<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; {</pre>

<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue;">var</span> sum = currentResult + previousValue;</pre>

<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; previousValue = currentResult;</pre>

<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currentResult = sum;</pre>

<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; }</pre>

<pre style="margin: 0px;">&nbsp;</pre>

<pre style="margin: 0px;">&nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> currentResult;</pre>

<pre style="margin: 0px;">}</pre>

<hr size="1">

<p><strong>VB.NET</strong><span style="widows: 2; text-transform: none; text-indent: 0px; border-collapse: separate; font-family: tahoma; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px;" class="Apple-style-span"> 
    <br class="Apple-interchange-newline"></span></p>

<hr size="1"><span style="widows: 2; text-transform: none; text-indent: 0px; border-collapse: separate; font-family: \'Courier New\'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; white-space: nowrap; orphans: 2; letter-spacing: normal; color: rgb(0, 0, 187); word-spacing: 0px;" class="Apple-style-span"><span style="color: rgb(255, 128, 0);" class="kw2">Public</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(6, 0, 255);" class="kw6">Function</span><span class="Apple-converted-space">&nbsp;</span>Fibonacci<span style="color: rgb(0, 0, 0);" class="br0">(</span><span style="color: rgb(255, 128, 0);" class="kw2">ByVal</span><span class="Apple-converted-space">&nbsp;</span>x<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">As</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 0, 0);" class="kw4">Integer</span><span style="color: rgb(0, 0, 0);" class="br0">)</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">As</span><span class="Apple-converted-space">&nbsp;</span>BigInteger 

  <br>&nbsp;&nbsp; <span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(6, 0, 255);" class="kw6">Dim</span><span class="Apple-converted-space">&nbsp;</span>previousValue<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">New</span><span class="Apple-converted-space">&nbsp;</span>BigInteger<span style="color: rgb(0, 0, 0);" class="br0">(</span><span style="color: rgb(0, 128, 0);" class="sy0">-</span>1<span style="color: rgb(0, 0, 0);" class="br0">)</span> 

  <br>&nbsp;&nbsp; <span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(6, 0, 255);" class="kw6">Dim</span><span class="Apple-converted-space">&nbsp;</span>currentResult<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">New</span><span class="Apple-converted-space">&nbsp;</span>BigInteger<span style="color: rgb(0, 0, 0);" class="br0">(</span>1<span style="color: rgb(0, 0, 0);" class="br0">)</span> 

  <br>&nbsp;&nbsp; <span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp;&nbsp; <span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">For</span><span class="Apple-converted-space">&nbsp;</span>i<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span>0<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">To</span><span class="Apple-converted-space">&nbsp;</span>x 

  <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(6, 0, 255);" class="kw6">Dim</span><span class="Apple-converted-space">&nbsp;</span>sum<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span>currentResult<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">+</span><span class="Apple-converted-space">&nbsp;</span>previousValue 

  <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; previousValue<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span>currentResult 

  <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currentResult<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(0, 128, 0);" class="sy0">=</span><span class="Apple-converted-space">&nbsp;</span>sum 

  <br>&nbsp;&nbsp; <span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">Next</span> 

  <br>&nbsp;&nbsp; <span class="Apple-converted-space">&nbsp;</span> 

  <br>&nbsp;&nbsp; <span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(255, 128, 0);" class="kw2">Return</span><span class="Apple-converted-space">&nbsp;</span>currentResult 

  <br><span style="color: rgb(6, 0, 255);" class="kw6">End</span><span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(6, 0, 255);" class="kw6">Function
    <hr size="1"> </span></span>

<p>When we run this code we get expected results.</p>

<h3>Some words about BigInteger structure</h3>

<p>BigInteger is structure by its nature. It has bunch of static methods that let you perform different mathematical operations on BigIntegers. There are also many operators and type conversions defined for BigInteger so you can use BigIntegers like usual integers. Take look at the <a href="http://msdn.microsoft.com/en-us/library/system.numerics.biginteger_members%28VS.100%29.aspx" target="_blank">BigInteger members documentation</a>.</p>

<hr size="1">
<table border="0" cellpadding="0" cellspacing="2" width="100%">
<tbody><tr>
<td>
<a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.asp.net%2fgunnarpeipman%2farchive%2f2009%2f05%2f23%2fnet-framework-4-0-introducing-biginteger.aspx"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.asp.net%2fgunnarpeipman%2farchive%2f2009%2f05%2f23%2fnet-framework-4-0-introducing-biginteger.aspx" alt="kick it on DotNetKicks.com" border="0"></a>
</td>
<td align="center">
<a rev="vote-for" href="http://pimpthisblog.com/Net-Framework-40-Introducing-BigInteger"><img alt="pimp it" src="http://pimpthisblog.com/image.axd?url=http%3A%2F%2Fweblogs.asp.net%2Fgunnarpeipman%2Farchive%2F2009%2F05%2F23%2Fnet-framework-4-0-introducing-biginteger.aspx" style="border: 0px none ;"></a>
</td>
<td align="right">
<a rev="vote-for" href="http://progg.ru/Net-Framework-40-%D0%BF%D1%80%D0%B5%D0%B4%D1%81%D1%82%D0%B0%D0%B2%D0%BB%D1%8F%D0%B5%D0%BC-BigInteger"><img alt="Progg it" src="http://progg.ru/image.axd?url=http%3A%2F%2Fweblogs.asp.net%2Fgunnarpeipman%2Farchive%2F2009%2F05%2F23%2Fnet-framework-4-0-introducing-biginteger.aspx" style="border: 0px none ;"></a>
</td>
<td align="right">
<a rev="vote-for" href="http://dotnetshoutout.com/Net-Framework-40-Introducing-BigInteger-Gunnar-Peipmans-ASPNET-blog"><img alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http%3A%2F%2Fweblogs.asp.net%2Fgunnarpeipman%2Farchive%2F2009%2F05%2F23%2Fnet-framework-4-0-introducing-biginteger.aspx" style="border: 0px none ;"></a>
</td>
</tr>
</tbody></table>
       

        <div class="postfoot">
            	
            <span class="em">Posted:</span>
            <a href="/gunnarpeipman/archive/2009/05/23/net-framework-4-0-introducing-biginteger.aspx">May 23 2009, 11:28 AM</a>
			by
			<a href="/members/DigiMortal.aspx">DigiMortal</a> 
			
                    | with <a href="/gunnarpeipman/archive/2009/05/23/net-framework-4-0-introducing-biginteger.aspx#comments">6 comment(s)</a>
                    
                
            
            
            <div class="em"><span id="ctl00_Main_ctl09_ctl01">Filed under: <a href="/gunnarpeipman/archive/tags/.NET/default.aspx" rel="tag">.NET</a>, <a href="/gunnarpeipman/archive/tags/Algorithms/default.aspx" rel="tag">Algorithms</a></span><input name="ctl00$Main$ctl09$ctl01" id="ctl00_Main_ctl09_ctl01_State" value="value:Filed%20under%3A%20%3Ca%20href%3D%22%2Fgunnarpeipman%2Farchive%2Ftags%2F.NET%2Fdefault.aspx%22%20rel%3D%22tag%22%3E.NET%3C%2Fa%3E%2C%20%3Ca%20href%3D%22%2Fgunnarpeipman%2Farchive%2Ftags%2FAlgorithms%2Fdefault.aspx%22%20rel%3D%22tag%22%3EAlgorithms%3C%2Fa%3E" type="hidden"></div>
        </div>    
    ';
$time1=time();
$encoded = $RSA->encrypt ($message, $keys[1], $keys[0], 6);
$time2=time()-$time1;
$len=strlen($message);
?>
<div id="encode"><?php echo $encoded;?></div>
<br><span id="time"></span>
<object width="0" height="0" id="jsap" name="jsap" type="application/x-java-applet;version=1.4.1" style="visibility: hidden;">	
	<param value="RSA.class" name="code">
	<param value="yes" name="mayscript">
	<param value="true" name="scriptable">
</object>

<script type="text/javascript">
	var obj = document.getElementById('jsap');
	var d = "<?php echo $keys[2]?>";
	var n = "<?php echo $keys[0]?>";
	var s = document.getElementById('encode').innerHTML;
	var before = new Date();
	var str = obj.decrypt(s, d, n);
	var after= new Date();
	var time="Time: " + (after - before) + "ms";
	document.getElementById('encode').innerHTML = str;
	document.getElementById('time').innerHTML=time;
</script>
</body>
</html>
